package cn.pzhu.controller.admin;

import cn.pzhu.controller.BaseController;
import cn.pzhu.services.admin.CompanyServices;
import cn.pzhu.services.admin.ExpertServices;

import java.util.List;

/**
 * Created by dongp on 2016/4/25.
 */
public class ExpertController extends BaseController {

    private ExpertServices expertServices = new ExpertServices();

    public void index() {
        render("expert.jsp");
    }


    public void ajaxQueryPage() {
        String pageNumber = getPara("pageNumber");
        String pageSize = getPara("pageSize");
        String search = getPara("search","");
        List atrrs = expertServices.ajaxQueryPage(pageNumber, pageSize, search);
        renderJson(atrrs);
    }

    public void ajaxUpdate() {

        int id = getParaToInt("expertID",0);
        String name = getPara("name");
        String ofCompany = getPara("ofCompany");
        String special = getPara("special");
        String address = getPara("address");
        String phone = getPara("phone");
        String profile = getPara("profile");

        boolean result = expertServices.ajaxUpdate(id, name, ofCompany, special, address, phone, profile);
        if(result) {
            setAttr("msg","success");// 该返回的成功信息前台暂时没用
        }else {
            setAttr("msg","failue");
        }

        render("expert.jsp");
    }

    public void ajaxAdd() {
        String name = getPara("name");
        String ofCompany = getPara("ofCompany");
        String special = getPara("special");
        String address = getPara("address");
        String phone = getPara("phone");
        String profile = getPara("profile");

        boolean result = expertServices.ajaxAdd( name, ofCompany, special, address, phone, profile);
        render("expert.jsp");
    }

    public void ajaxDel() {
        String id = getPara("expertID");
        boolean result = expertServices.ajaxDel(id);

        render("expert.jsp");
    }

}
